package tech.aistar.day04;

import java.util.Scanner;

/**
 * 本类用来演示:
 *
 * @author: success
 * @date: 2021/3/9 4:10 下午
 */
public class TestScannerClose {
    public static void main(String[] args) {
        int n = nextInt2();
        System.out.println(n);

        int n2 = nextInt2();
        System.out.println(n2);
    }

    public static int nextInt(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        //在jdk8.0之前的版本的话,那么System.in得到的是InputStream字节输入流的对象
        //学习IO流 - 流本身也是资源/对象 - 昂贵的资源
        //sc.close();
        return n;
    }

    public static int nextInt2(){
        int n = 0;
        try(Scanner sc = new Scanner(System.in)){//sc使用完毕之后将会由JVM自动关闭...
            n = sc.nextInt();
        }
        return n;
    }

}
